<%@ page import="com.biz.conf.Global" %>
<%@ page import="com.framework.utils.ConfigUtil" %>
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/jsp/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>久零商品专区</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="${ctxStatic}/plugins/h+/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/animate.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="${ctxStatic}/plugins/h+/css/plugins/webuploader/webuploader.css">
    <link href="${ctxStatic}/plugins/h+/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <style>
        .fancybox img {
            margin-bottom: 5px;
            width: 80px;
            height: 80px;
        }
        .h3tip{
            font-size: 14px;
            color:#fc0d08;
        }
        .changetable{
            width:90%;
            float: right;
            border:1px solid #e5e6e7;
            border-right: 0;
            border-bottom: 0;
        }
        .changetable thead tr th{
            border-bottom: 1px solid #e5e6e7;
            border-right: 1px solid #e5e6e7;
            padding:4px 0;
            text-align: center;
        }
        .changetable tbody tr td{
            border-bottom: 1px solid #e5e6e7;
            border-right: 1px solid #e5e6e7;
            padding:4px 0;
            text-align: center;
        }
        .priceinput,.numinput{
            width:80px;
            margin:0 auto;
            border-radius:6px;
            padding: 2px;
        }
        .borbreak{
            border-top: 1px solid #ccc;
            margin-top: 20px;
            padding-top: 20px;
        }
    </style>

</head>

<body class="gray-bg" >
<div class="wrapper wrapper-content">

    <%--<div class="panel-body">--%>
        <form class="form-horizontal"  id="postForm" name="postForm">
            <input type="hidden" id="idHidden" name="pwxgoods.id">
            <div class="tab-content">
                <div id="tab-0" class="tab-pane active">
                    <div class="ibox-content">
                        <div class="form-group">
                            <h3 class="m-t-none m-b">1.商品信息</h3>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">商品名：</label>
                            <div class="col-sm-9">
                                <input readonly id="nameTxt" type="text" class="form-control">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">商品编码：</label>
                            <div class="col-sm-9">
                                <input readonly id="codeTxt" type="text" class="form-control">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">品牌：</label>
                            <div class="col-sm-9">
                                <input readonly id="brandTxt" type="text" class="form-control">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">标签：</label>
                            <div class="col-sm-9">
                                <input readonly id="tagTxt" type="text" class="form-control" placeholder="默认标签">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">单位：</label>
                            <div class="col-sm-9">
                                <input readonly id="unitTxt" type="text" class="form-control" placeholder="">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">商品图：</label>
                            <div class="col-sm-9">
                                <div id="picDiv" class="">
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <h3 class="m-t-none m-b">2.修改库存<span class="h3tip">(谨慎修改,会覆盖该商品原有属性、库存信息)</span></h3>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-12">

                                <table class="changetable">
                                    <thead id="stockThead"></thead>
                                    <tbody id="stockTbody"></tbody>
                                </table>
                            </div>
                        </div>

                        <div class="form-group">
                            <h3 class="m-t-none m-b">3.其他</h3>
                        </div>

                        <%--<div class="form-group">--%>
                            <%--<label class="col-sm-3 control-label">每人限购：</label>--%>
                            <%--<div class="col-sm-9">--%>
                                <%--<input readonly id="limitTxt" type="text" class="form-control"> <span class="help-block m-b-none">0代表不限购</span>--%>
                            <%--</div>--%>
                        <%--</div>--%>
                        <%--<div class="form-group">--%>
                            <%--<label class="col-sm-3 control-label">开售时间：</label>--%>
                            <%--<div class="col-sm-9">--%>
                                <%--<div class="radio i-checks">--%>
                                    <%--<label><input id="isPromptly_0" type="radio" value="0" name="a" disabled> <i></i> 立即开售</label>--%>
                                    <%--<label><input id="isPromptly_1" type="radio" value="1" name="a" disabled> <i></i>定时开售 </label>--%>
                                <%--</div>--%>
                            <%--</div>--%>
                        <%--</div>--%>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">商品详情：</label>
                            <div class="col-sm-9">
                                <script id="container_bj" name="content" type="text/plain"></script>
                            </div>
                        </div>


                        <div class="form-group borbreak">
                            <div class="col-sm-offset-3 col-sm-8">
                                <button class="btn btn-primary" type="button" onclick="submitForm();">确定</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>

    <%--</div>--%>
</div>


<script>
    $(document).ready(function(){var editor=new Simditor({textarea:$("#editor"),defaultImage:"img/a9.jpg"})});
</script>
<script src="${ctxStatic}/plugins/h+/js/plugins/iCheck/icheck.min.js"></script>
<script>
    $(document).ready(function(){$(".i-checks").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",})});
</script>
<script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>

<script src="${ctx}/resources/plugins/ueditor1_4_2-utf8-jsp/ueditor.config.js"></script>
<script src="${ctx}/resources/plugins/ueditor1_4_2-utf8-jsp/ueditor.all.min.js"></script>
<script src="${ctx}/resources/plugins/ueditor1_4_2-utf8-jsp/lang/zh-cn/zh-cn.js"></script>
<%--<script src="${ctxStatic}/plugins/ueditor1_4_2-utf8-jsp/ueditor.config.js"></script>--%>
<%--<script src="${ctxStatic}/plugins/ueditor1_4_2-utf8-jsp/ueditor.all.min.js"></script>--%>
<%--<script src="${ctxStatic}/plugins/ueditor1_4_2-utf8-jsp/lang/zh-cn/zh-cn.js"></script>--%>

<script src="${ctxStatic}/plugins/h+/js/jquery.min.js?v=2.1.4"></script>
<script src="${ctxStatic}/plugins/h+/js/bootstrap.min.js?v=3.3.6"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/bootstrap-table.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/locale/bootstrap-table-zh-CN.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/extensions/export/bootstrap-table-export.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/extensions/editable/bootstrap-table-editable.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/sweetalert/sweetalert.min.js"></script>
<script src="${ctxStatic}/plugins/h+/js/content.min.js?v=1.0.0"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/layer/laydate/laydate.js"></script>
<script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>
<script type="text/javascript">
    var index = parent.layer.getFrameIndex(window.name);
    var tools= [[
        'source', '|', 'undo', 'redo', '|',
        'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain',
        '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
        'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
        'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
        'directionalityltr', 'directionalityrtl', 'indent', '|',
        'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase',
        '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
        'simpleupload', 'insertimage',  'map', '|',
        'horizontal', '|', 'print', 'preview', 'searchreplace'
    ]];
    //编辑部分富文本编辑器
    var uebj = UE.getEditor('container_bj', {
        scaleEnabled: true,
        //initialFrameHeight:200,
        toolbars: tools
    });

    uebj.addListener("ready", function () {
        //editor准备好之后才可以使用
        uebj.setContent('${twxgoods.info }');
        uebj.setDisabled();
    });

    $(function () {
        var id = '${id}';
        console.log("id:" + id);
        loadGoodsInfo(id);
    });

    function loadGoodsInfo(id) {

        $.ajax({
            url: "${pageContext.request.contextPath}/mall/getGoodsSkuFromChain.ac?id="+id,
            async: false,
            success: function (dateChain) {
                dateChain=jQuery.parseJSON(dateChain);
//                data = jQuery.parseJSON(data);
                console.log(dateChain);
                loadPage(dateChain);
            }
        });

    }

    function loadPage(objChain) {
        $("#idHidden").val(objChain.id);
        $("#nameTxt").val(objChain.name);
        $("#codeTxt").val(objChain.code);
        $("#brandTxt").val(objChain.brandName);

        var picList = objChain.coverList;
        var picStr = "";
        $(picList).each(function(index,value){
            picStr += '<a class="fancybox" href="javascript:;"><img alt="image" src="<%=ConfigUtil.get("OSSURL")%>' + value.coverPath + '" /></a>&nbsp;&nbsp;';
        });
        $("#picDiv").html(picStr);

        $("#tagTxt").val(objChain.tagName);
        $("#unitTxt").val(objChain.unitName);

        var thhtml = '<tr>';
        for(var i=0;i<objChain.stockParList.length;i++) {
            thhtml += " <th>"+objChain.stockParList[i].name+"</th>" ;
        }
        thhtml += '<th>价格</th><th>库存</th><th>商品编码</th>';
        thhtml += '</tr>';

        var trhtml = '';
        for(var i=0;i<objChain.stocklist.length;i++) {
            trhtml += "<tr>";
//            var dat = obj.stocklist[i];
            var datChain = objChain.stocklist[i];

            trhtml += '<input type="hidden" value="' + datChain.id + '" name="pwxgoods.stockId" />';
            if (datChain.typesId1 != "" && datChain.typesId1 != undefined && datChain.typesId1 != null) {
                trhtml += '<td>' + datChain.standard1Name + '</td>';
            }
            if (datChain.typesId2 != "" && datChain.typesId2 != undefined && datChain.typesId2 != null) {
                trhtml += '	<td>' + datChain.standard2Name + '</td>';
            }
            if (datChain.typesId3 != "" && datChain.typesId3 != undefined && datChain.typesId3 != null) {
                trhtml += '	<td>' + datChain.standard3Name + '</td>';
            }
            trhtml += '<td><input type="text" readonly class="form-control priceinput" name="pwxgoods.price" value="' + datChain.price + '"/></td>';
//            trhtml += '<td><input type="text" readonly class="form-control priceinput" value="' + datChain.priceJiuling + '"/></td>';
//            trhtml += '<td><input type="text" readonly class="form-control numinput" name="pwxgoods.stock" value="' + stock + '"/></td>';
            trhtml += '<td><input type="text" readonly class="form-control numinput" value="' + datChain.stock + '"/></td>';
            trhtml += '<td><input type="text" readonly class="form-control numinput" value="' + datChain.venderId + '"/></td>';
//            if(datChain.id==dat.id) {
//                trhtml += '<td><input type="text" class="form-control priceinput" name="pwxgoods.price" value="' + dat.priceDiaopai + '"/></td>';
//                trhtml += '<td><input type="text" readonly class="form-control priceinput" value="' + datChain.priceJiuling + '"/></td>';
//                trhtml += '<td><input type="text" class="form-control numinput" name="pwxgoods.stock" value="' + dat.stock + '"/></td>';
//                trhtml += '<td><input type="text" readonly class="form-control numinput" value="' + datChain.stock + '"/></td>';
//                trhtml += '<td><input type="text" readonly class="form-control numinput" value="' + datChain.venderId + '"/></td>';
//            }else{
//                trhtml += '<td><input type="text" class="form-control priceinput" name="pwxgoods.price" value="' + dat.priceDiaopai + '"/></td>';
//                trhtml += '<td><input type="text" readonly class="form-control priceinput" value=""/></td>';
//                trhtml += '<td><input type="text" class="form-control numinput" name="pwxgoods.stock" value="' + dat.stock + '"/></td>';
//                trhtml += '<td><input type="text" readonly class="form-control numinput" value=""/></td>';
//                trhtml += '<td><input type="text" readonly class="form-control numinput" value="' + dat.venderId + '"/></td>';
//            }
            trhtml += "</tr>";
        }

        $("#stockThead").html(thhtml);
        $("#stockTbody").html(trhtml);

        <%--$("#limitTxt").val('${twxgoods.countLimit}');--%>
        <%--if('${twxgoods.countLimit}'=='0'){--%>
            <%--$("#isPromptly_0").attr('checked','true');--%>
        <%--}else  if('${twxgoods.countLimit}'=='1'){--%>
            <%--$("#isPromptly_1").attr('checked','true');--%>
        <%--}--%>

    }

    function submitForm() {
        parent.layer.close(index);
        <%--var url = '${pageContext.request.contextPath}/mall/updateStockAndPrice.ac';--%>
        <%--console.log('data:'+$('#postForm').serialize());--%>
        <%--$.ajax({--%>
            <%--type: "POST",--%>
            <%--url: url,--%>
            <%--data: $('#postForm').serialize(),// 你的formid--%>
            <%--async: false,--%>
            <%--error: function (request) {--%>
                <%--alert("连接失败");--%>
            <%--},--%>
            <%--success: function (data) {--%>
                <%--console.log(data);--%>
                <%--if(data.success==true) {--%>
                    <%--alert("操作成功！");--%>
                    <%--parent.layer.close(index);--%>
                <%--}else{--%>
                    <%--alert("操作失败！");--%>
                <%--}--%>
            <%--}--%>
        <%--});--%>
    }

</script>
</body>


</html>
